#:import Window kivy.core.window.Window
#:import Factory kivy.factory.Factory
#:import C kivy.utils.get_color_from_hex
#:import SwapTransition kivy.uix.screenmanager.FadeTransition
#:set common app.theme[app.system_config['theme']]['common']
#:set gray [.99,.99,.99]
#:set dark_gray [.9,.9,.9]
#:set white [1,1,1]
#:set black [0,0,0]
#:set hex_light_black '#a0a0a0'

<Widget>:
    font_name: 'kai'
    text_language: 'zh_CN'
##    on_touch_down: app.grab_or_not(args)
##    c_a_a: 0
##    canvas.after:
##        Color:
##            rgba: [0]*3+[self.c_a_a]
##        Rectangle:
##            pos: self.pos
##            size: self.size
    

<BlockImage@Image+Block>:

<BlockGridLayout@GridLayout+Block>:

<ColoredGridLayout@GridLayout>:
    c0: app.theme_color
    force_set: False
    reset_c0: []
    
    canvas.before:
        Color:
            rgb: self.reset_c0 if self.reset_c0 else (self.c0 or common)
        Rectangle:
            pos: self.pos
            size: self.size

<BlockColoredGridLayout@ColoredGridLayout+Block>:
    
<ColoredFloatLayout@FloatLayout>:
    c0: app.theme_color
    canvas.before:
        Color:
            rgb: self.c0 or common
        Rectangle:
            pos: self.pos
            size: self.size

<ScrollView@Block>:
    c0: [1]*3
    scroll_timeout: 30000
    scroll_distance: 1
    effect_cls: app.S
    size_hint: (1,1)
    do_scroll_x: False
    on_scroll_start: app.touch_scrllview(args, touch_on=True)
    on_scroll_stop: app.touch_scrllview(args, touch_on=False)
##    dont_check_children: hasattr(self,'viewclass')
    
    
<LeftLabel@Label>:
    color: C('#101010')
    font_size: app.font_size
    text_size: (self.width, None)
    size_hint: (1, None)
    height: self.texture_size[1]
    halign: 'left'
    valign: 'middle'
    
<FixedHeightLeftLabel@Label>:
    color: C('#101010')
    text_size: (None, self.height)
    size_hint: (None, 1)
    width: self.texture_size[0]
    halign: 'left'
    valign: 'middle'
    
<MiddleLabel@Label>:
    color: C('#101010')
    font_size: app.font_size

<ShortenLabel@Label>:
    color: C('#101010')
##    font_size: app.font_size
    shorten: True
    halign: 'left'
    text_size: [self.width, None]
    

<TextInput>:
    idd: 'textinput'
    on_touch_down: app.touch_on_layout(args)
    on_text: self.do_cursor_movement('cursor_end')
    background_color: (0,0,0,0)
    cursor_color: (1,1,1,1)
    foreground_color: (1,1,1,1)
    font_size: app.font_size
    multiline: False
    padding: [10, 0.5 * (self.height - self.line_height)]
    text_language: 'zh_CN'

<SpecialRecycleView@GridLayout>:
    viewclass: ''
    data: []
    data_bak: []
    size_hint_y: None
    on_data: app.special_rv_data_changed(args)
    
<ToolGLayout@GridLayout>:
    t0: '?'
    i0: 'src/favorite.png'
    cols: 1
    GridLayout:
        rows: 1
        Label:
            size_hint_x: None
            width: root.width*.02

        Image:
            size_hint_x: None
            width: self.height*.9
            source: self.parent.parent.i0
            color: (app.theme_color or common)+[1, ]

        Label:
            size_hint_x: None
            width: root.width*.02

        FixedHeightLeftLabel:
            text: self.parent.parent.t0

    GridLayout:
        rows: 1
        size_hint_y: .015
        canvas.before:
            Color:
                rgb: dark_gray
            Rectangle:
                size: self.size
                pos: self.pos


<PlaylistGlayout@GridLayout>:
    size_hint_y: None
    height: app.height*.1
    on_touch_up: app.touch_on_layout(args)
    idd: 'music_list'
    rows: 1
    c1: []

    playlist_id: ''
    t0: '1'
    t1: '0首 by Lua'
    i0: 'src/logo.jpg'
    
    Image:
        size_hint_x: None
        width: self.height
        source: self.parent.i0

    GridLayout:
        size_hint_x: None
        width: self.minimum_width
        cols: 1
        FixedHeightLeftLabel:
            size_hint_y: 2
            font_size: min(app.font_size,self.height*.7)
            text: self.parent.parent.t0 if self.parent.height else ''

        FixedHeightLeftLabel:
            size_hint_y: 1
            font_size: min(app.font_size*.7,self.height)
            text: self.parent.parent.t1 if self.parent.height else ''
            
    Label:

    Image:
        idd: 'point'
        size_hint_x: None
        width: self.height*.7
        color: app.bg_color_1
        source: 'src/point.png'

<PlaylistsRecycleView@RecycleView>:
    viewclass: 'PlaylistGlayout'
    data: []
    size_hint_y: None
    height:0
    content_default_size: [None, app.height*.1]
    is_ugly_rv: True
##    on_touch_down: self.parent.on_touch_down(args[1]);print(self.parent)
##    on_touch_up: self.parent.on_touch_up(args[1])
##    on_touch_move: self.parent.on_touch_move(args[1])
    
    RecycleGridLayout:
        canvas.before:
            Color:
                rgb: app.bg_color
            Rectangle:
                size: self.size
                pos: self.pos
                
        cols: 1
        default_size: self.parent.content_default_size
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        on_height: self.parent.height=self.height

<PlaylistManager@ColoredGridLayout>:
    idd: 'pl_manager'
    reset_c0: app.bg_color_1
    t0: 'S(0)'
    opened: False
    content_data:[]
    on_content_data: self.opened=True
    on_touch_up: app.touch_on_layout(args)
    cols: 1
    size_hint_y: None
    height: self.minimum_height
    
    GridLayout:
        rows: 1
        size_hint_y: None
        height: app.height*.04
        GridLayout:
            rows: 1
            Image:
                size_hint_x: None
                width: self.height*1.5
                color: black+[1]
                source: 'src/down.png' if self.parent.parent.parent.opened else 'src/right.png'
                
            FixedHeightLeftLabel:
                text: self.parent.parent.parent.t0

        GridLayout:
            size_hint_x: 4

        Image:
            pos: self.parent.pos[0]+self.parent.width*.88, self.pos[1]
            source: 'src/setting.png'
            
    PlaylistsRecycleView:
        data: self.parent.content_data
        content_default_size: [None, app.height*.1] if self.parent.opened else [None, 0]

<SingleMusicGlayout@GridLayout>:
    rows: 1
    size_hint: 1, None
    height: app.height*.08
    idd: 'song'
    on_touch_up: app.touch_on_layout(args)
    max_len: 23
    d_info: {}
    n0: '1'
    t0: '还没有缓存音乐哦'
    t1: 'Yourself'
    
    MiddleLabel:
        size_hint_x: None
        width: self.height*2
        text: self.parent.n0

    GridLayout:
        cols: 1

        ShortenLabel:
            size_hint_y:2
            text: self.parent.parent.t0

        ShortenLabel:
            color: C(hex_light_black)
            text: self.parent.parent.t1

    Image:
        idd: 'show_song_bubble'
        on_touch_up: app.touch_on_layout(args)
        size_hint_x: None
        width: self.height*.7
        color: dark_gray+[1]
        source: 'src/point.png'


<RecommendPlaylist@GridLayout>:
    cols: 1
    size_hint_y: None
    height: self.minimum_height
    idd: 'music_list'
    on_touch_up: app.touch_on_layout(args)
    
    s0: ''
    t0: ''
    playlist_id: '0000'
    
    Image:
        size_hint_y: None
        height: app.width/3
        allow_stretch: True
        source: self.parent.s0

    Label:
        color: C('#000000')
        size_hint_y: None
        valign: 'top'
        text_size: self.size
        height: self.font_size*2.7
        font_size: app.font_size*.7
        text: self.parent.t0

<RecPlRecycleView@RecycleView>:
    viewclass: 'RecommendPlaylist'
    data: []
    size_hint_y: None
    height:0
    content_default_size: [None, app.height*.4]
    is_ugly_rv: True
    
    RecycleGridLayout:
        canvas.before:
            Color:
                rgb: app.bg_color
            Rectangle:
                size: self.size
                pos: self.pos
                
        cols: 3
        default_size: self.parent.content_default_size
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        on_height: self.parent.height=self.height

<RecommendPLManager@GridLayout>:
    cols: 1
    size_hint_y: None
    height: self.minimum_height
    content_data:[]
    
    LeftLabel:
        size_hint_y: None
        height: self.font_size*1.2
        text: '推荐歌单 >'

    RecPlRecycleView:
        data: self.parent.content_data

<SideBarBox@GridLayout>:
    idd: ''
    i0: ''
    t0: ''
    on_touch_up: app.touch_on_layout(args)
    rows: 1
    size_hint_y: None
    height: app.height/15
    
    Image:
        size_hint_x: None
        width: self.height
        source: self.parent.i0

    FixedHeightLeftLabel:
        size_hint_x: None
        width: self.font_size*len(self.text)
        text: self.parent.t0

<SongsRecycleView@RecycleView>:
    viewclass: 'SingleMusicGlayout'
    data: []
    RecycleGridLayout:
        cols: 1
        default_size: None, app.height*.08
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height

<NoticeBox@AnchorLayout+Block>:
    anchor_x: 'center'
    anchor_y: 'center'
    c0_a: [0]*3+[.7]
    content_c0: [1]*3
    size_ratio: [.7,.2]
    title: '登录失败'
    content_text: '用户名或密码错误'
    separator_color: dark_gray
    ensure_text: '确定'

    canvas.before:
        Color:
            rgba: self.c0_a
        Rectangle:
            pos: self.pos
            size: self.size

    GridLayout:
        cols: 1
        size_hint: None, None
        size: [self.parent.width*self.parent.size_ratio[0], self.parent.height*self.parent.size_ratio[1]]
        canvas.before:
            Color:
                rgb: self.parent.content_c0
            RoundedRectangle:
                radius: [self.height*.05]
                pos: self.pos
                size: self.size

        MiddleLabel:
            size_hint_y: 2
            text: self.parent.parent.title
        MiddleLabel:
            font_size: app.font_size*.7
            text: self.parent.parent.content_text
        ColoredGridLayout:
            cols: 1
            c0: self.parent.parent.separator_color
            size_hint_y: .05
        Button:
            idd: 'delete'
            size_hint_x: None
            width: self.parent.width-self.height*.2
            center: self.parent.center[0], self.center[1]
            color: [0]*3+[1]
            text: self.parent.parent.ensure_text
            background_normal: ''
            on_release: self.parent.parent.parent.remove_widget(self.parent.parent)

<MusicBubble@Bubble+Block>:
    selected_widget: None
    on_touch_up: self.parent.remove_widget(self)
    arrow_pos: 'bottom_right'
    size_hint: [None]*2
    height: app.font_size*3
    
    BubbleButton:
        size_hint_x: None
        width: (len(self.text)+2)*self.font_size
        text: '删除'
        on_press: app.delete_music(self.parent.parent.selected_widget)

ScreenManager:
    is_playing: False

    on_height: app.set_playbar_height_to_zero()
    transition: SwapTransition(duration=.1)
    Screen:
        name: 'home'

        ColoredGridLayout:
            reset_c0: app.bg_color
            
            id: home_root
            cols: 1
            ColoredGridLayout:
                cols: 1
                size_hint_y: .4
                id:common_box
                
                
                GridLayout:
                    cols: 1
                    size_hint_y: .3 if not app.is_android else 0
                    
                GridLayout:
                    rows: 1
                    id:common_0
                    focus_n: 0
                    
                    size_hint_y: 1.5
                    Image:
                        source: 'src/menu.png'
                        idd: 'menu'
                        on_touch_up: app.touch_on_layout(args)
                        
                    Label:
                        
                    Image:
                        source: 'src/top_music.png'
                        idd: 'music'
                        color: white+[1 if self.parent.focus_n==0 else .5]
                        on_touch_up: app.touch_on_layout(args)
                        
                    Image:
                        source: 'src/wyy.png'
                        idd: 'wyy'
                        color: white+[1 if self.parent.focus_n==1 else .5]
                        on_touch_up: app.touch_on_layout(args)
                        
                    Image:
                        source: 'src/video.png'
                        idd: 'video'
                        color: white+[1 if self.parent.focus_n==2 else .5]
                        on_touch_up: app.touch_on_layout(args)

                    Label:
                    
                    Image:
                        idd: 'search'
                        source: 'src/search.png'
                        on_touch_up: app.touch_on_layout(args)

            GridLayout:
                size_hint_y:5
                id: first_scroll
                cols: 1

                ColoredGridLayout:
                    id: red_space
                    cols: 1
                    size_hint: None,None
                    width: root.width
                    height: root.height*.01
                    
                GridLayout:
                    id: first_scroll_glayout
                    rows: 1
                    size_hint_x: None
                    width: self.parent.size[0]
                    
                    ScrollView:
                        id: first_page_s
                        size_hint_x: None
                        width: root.width
                        
                        GridLayout:
                            id: first_page_s_g
                            cols: 1
                            size_hint: None,None
                            width: root.width
                            height: self.minimum_height

                            
                            GridLayout:
                                id: user_info_box
                                rows: 1
                                size_hint: 1,None
                                height: root.height*.10
                                c1: app.bg_color_0
                                
                                canvas.before:
                                    Color:
                                        rgb: app.theme_color or common
                                    Rectangle:
                                        size: self.width,self.height*.5
                                        pos: self.pos[0], self.center[1] 
                                        
                                    Color:
                                        rgb: self.c1 or gray
                                    RoundedRectangle:
                                        radius: [self.height*.2]*2+[0]*2
                                        size: self.size[0]*.98,self.size[1]*.95
                                        pos: self.width*.01,self.pos[1]+self.height*.025

##                                    Color:
##                                        rgb: self.c1 or gray
##                                    Rectangle:
##                                        size: self.size[0]*.98,self.size[1]*.05
##                                        pos: self.width*.01,self.pos[1]+self.height*.025

                                Label:
                                    size_hint_x: None
                                    width: root.width*.03
                                    
                                GridLayout:
                                    update_controler: False
                                    id: avatar_image_1
                                    rows: 1
                                    size_hint_x: None
                                    width: self.height
                                    canvas.before:
                                        Ellipse:
                                            source: app.avatar_fn if not self.update_controler else ''
                                            size: self.height*.90,self.height*.90
                                            pos: self.pos[0], self.pos[1]+root.height*.005

                                Label:
                                    size_hint_x: None
                                    width: root.width*.07
                                    
                                FixedHeightLeftLabel:
                                    id: avatar_text_1
                                    text: app.nickname
                                    

                                Label:

                                GridLayout:
                                    cols: 1
                                    id: vip_round
                                    size_hint_x: None
                                    width: app.font_size*5
                                    
                                    canvas.before:
                                        Color:
                                            rgb: app.theme_color or common
                                        Line:
                                            width: 1.01
                                            rounded_rectangle: (self.center[0]-app.font_size*2.5,self.center[1]-app.font_size*.6,app.font_size*5,app.font_size*1.2,app.font_size*.6,app.font_size*.6,app.font_size*.6,app.font_size*.6,100)
                                        
                                    Label:
                                        id: vip
                                        color: app.theme_color+[1,]
                                        font_size: app.font_size
                                        size_hint: (1, None)
                                        height: self.parent.height
                                        halign: 'center'
                                        valign: 'top'
                                        text: '开通会员'

                                Label:
                                    size_hint_x: .1
                                    
                            GridLayout:
                                id: func_box
                                cols: 1
                                size_hint_y: None
                                height: root.height*.4
                                
                                ToolGLayout:
                                    idd: 'local_music'
                                    on_touch_up: app.touch_on_layout(args)
                                    i0: 'src/music.png'
                                    t0: '本地音乐'

                                ToolGLayout:
                                    i0: 'src/nearly_play.png'
                                    t0: '最近播放'
                                 
                                ToolGLayout:
                                    i0: 'src/download_manager.png'
                                    t0: '下载管理'

                                ToolGLayout:
                                    i0: 'src/my_fm.png'
                                    t0: '我的电台'
                                 
                                ToolGLayout:
                                    i0: 'src/favorite.png'
                                    t0: '我的收藏'

                                ToolGLayout:
                                    i0: 'src/sati.png'
                                    t0: 'Sati空间'

                            PlaylistManager:
                                id: created_m_l_m
                                t0: '创建的歌单(0)'

                            PlaylistManager:
                                id: collected_m_l_m
                                t0: '收藏的歌单(0)'

                    GridLayout:
                        id: second_page_glayout
                        cols: 1
                        size_hint: None,1
                        width: root.width
                        f_s: app.font_size if self.width else 0
                        
                        ColoredGridLayout:
                            rows: 1
                            id: box_rec_mark
                            size_hint: None,None
                            height: root.height*.05
                            width: self.parent.width
                            
                            Label:
                                font_size: self.parent.parent.f_s
                                text: '推荐'
                                id: recommand
                                idd: 'recommand'
                                on_touch_up: app.touch_on_layout(args)

                            Label:
                                font_size: self.parent.parent.f_s
                                text: '朋友'
                                id: friend
                                idd: 'friend'
                                on_touch_up: app.touch_on_layout(args)
                                

                            Label:
                                font_size: self.parent.parent.f_s
                                text: '电台'
                                id: radio
                                idd: 'radio'
                                on_touch_up: app.touch_on_layout(args)

                        ColoredGridLayout:
                            rows: 1
                            size_hint: None,None
                            height: self.minimum_height
                            width: self.parent.width
                            
                            id: w_u_l
                            index_: 0
                            flag: '----' if self.width else ''
                            Label:
                                size_hint_y: None
                                height: self.font_size*.7
                                font_size: app.font_size
                                text: self.parent.flag if self.parent.index_==0 else ''
                            Label:
                                size_hint_y: None
                                height: self.font_size*.7
                                font_size: app.font_size
                                text: self.parent.flag if self.parent.index_==1 else ''
                            Label:
                                size_hint_y: None
                                height: self.font_size*.7
                                font_size: app.font_size
                                text: self.parent.flag if self.parent.index_==2 else ''

                        GridLayout:
                            id: scroll_glayout
                            cols: 3
                            size_hint: None,1
                            width: root.width*3
                            height: self.minimum_height
                            
                            ScrollView:
                                id: first_page_2_s
                                size_hint_x: None
                                width: root.width
                                do_scroll_x: False
                                
                                GridLayout:
                                    id: first_page_2
                                    cols: 1
                                    size_hint: None,None
                                    width: root.width
                                    height: self.minimum_height
                                    
                                    GridLayout:
                                        cols: 1
                                        size_hint: 1,None
                                        height: root.width*.33
                                        id: space_red
                                        
                                        canvas.before:
                                            Color:
                                                rgb: app.theme_color or common
                                            Rectangle:
                                                size: self.width,self.height*.7
                                                pos: self.pos[0], self.pos[1]+self.height*.3

                                        LeftLabel:
                                            size_hint_y: .05
                                            
                                        GridLayout:
                                            id: img_show
                                            rows: 1
                                            scaling_ratio: .95
                                            canvas.before:
                                                RoundedRectangle:
                                                    size: self.size[0]*self.scaling_ratio, self.size[1]*self.scaling_ratio
                                                    pos: self.pos[0]+self.width*(1-self.scaling_ratio)/2, self.pos[1]+self.height*(1-self.scaling_ratio)/2
                                                    source: 'src/image_show.jpg'

                                    Label:
                                        size_hint_y: None
                                        height: root.height*.02

                                    GridLayout:
                                        cols: 1
                                        size_hint_y: None
                                        height: root.height*.1
                                        id: box_pic_fm
                                        canvas.before:
                                            Color:
                                                rgb: app.theme_color or common
                                                
                                            Ellipse:
                                                pos: self.pos[0]+self.width/8-self.height*.8/2, self.pos[1]
                                                size: (self.height*.8, self.height*.8)
                                            Ellipse:
                                                pos: self.pos[0]+self.width/8-self.height*.8/2+ self.width/4, self.pos[1]
                                                size: (self.height*.8,self.height*.8)
                                            Ellipse:
                                                pos: self.pos[0]+self.width/8-self.height*.8/2+ self.width/2, self.pos[1]
                                                size: (self.height*.8,self.height*.8)
                                            Ellipse:
                                                pos: self.pos[0]+self.width/8-self.height*.8/2+ self.width/4*3, self.pos[1]
                                                size: (self.height*.8,self.height*.8)

                                        Label:
                                            size_hint_y: .5
                                            
                                        GridLayout:
                                            rows: 1
                                            Image:
                                                id: fm
                                                idd: 'fm'
                                                size_hint_y: None
                                                height: self.parent.parent.height*.5
                                                source: 'src/fm.png'

                                            Image:
                                                id: date
                                                idd: 'date'
                                                on_touch_up: app.touch_on_layout(args)
                                                size_hint_y: None
                                                height: self.parent.parent.height*.5
                                                source: 'src/date.png'

                                            Image:
                                                id: music_list
                                                idd: 'music_list'
                                                size_hint_y: None
                                                height: self.parent.parent.height*.5
                                                source: 'src/music_list.png'

                                            Image:
                                                id: top
                                                idd: 'top'
                                                size_hint_y: None
                                                height: self.parent.parent.height*.5
                                                source: 'src/top.png'

                                        
                                    FloatLayout:
                                        size_hint_y: None
                                        height: 5
                                        id: box_fm
                                        MiddleLabel:
                                            pos_hint: {'center_x':1/8, 'center_y': -2}
                                            id: l_fm
                                            text: '私人FM'

                                        MiddleLabel:
                                            pos_hint: {'center_x':1/8+1/4, 'center_y': -2}
                                            id: l_date
                                            text: '每日推荐'
                                            
                                        MiddleLabel:
                                            pos_hint: {'center_x':1/8+1/4*2, 'center_y': -2}
                                            id: l_ml
                                            text: '歌单'

                                        MiddleLabel:
                                            pos_hint: {'center_x':1/8+1/4*3, 'center_y': -2}
                                            id: l_top
                                            text: '排行榜'


                                    Label:
                                        size_hint_y: None
                                        text:''
                                        height:root.height*.07

                                    RecommendPLManager:
                                        id: recommand_m_l

                            ScrollView:
                                id: second_page_2_s
                                size_hint_x: None
                                width: root.width
                                do_scroll_x: False
                                
                                GridLayout:
                                    id: second_page_2
                                    cols: 1
                                    size_hint: None,None
                                    width: root.width
                                    height: self.minimum_height

                                    LeftLabel:
                                        text: '你哪来的朋友!'
                                        size_hint_y: None

                            ScrollView:
                                id: third_page_2_s
                                size_hint_x: None
                                width: root.width
                                do_scroll_x: False
                                
                                GridLayout:
                                    id: third_page_2
                                    cols: 1
                                    size_hint: None,None
                                    width: root.width
                                    height: self.minimum_height

                                    LeftLabel:
                                        text: '啥年代了听电台呢'

                    ScrollView:
                        id: third_page_s
                        size_hint_x: None
                        width: root.width
                        do_scroll_x: False
                        
                        GridLayout:
                            id: third_page_s_g
                            cols: 1
                            size_hint: None,None
                            width: root.width
                            height: self.minimum_height

                            ScrollView:
                                size_hint_y: None
                                height: root.height*.5
                                GridLayout:
                                    cols: 1
                                    size_hint_y: None
                                    height: self.minimum_height
                                    Label:
                                        id: debug_label
                                        size_hint_y: None
                                        font_size: app.font_size
                                        line_height: 2
                                        color: common+[.8,]
                                        text_size: self.size[0], None
                                        height: self.texture_size[1]
                                        halign: 'left'
                                        markup: True
                                        
                                        text: '...\n'*100

                            GridLayout:
                                cols: 1
                                size_hint: None,None
                                width: root.width
                                height: root.height*1
                                Label:
                                    size_hint_y: None
                                    font_size: app.font_size
                                    line_height: 2
                                    color: common+[.8,]
                                    text_size: self.size[0], None
                                    height: self.texture_size[1]
                                    halign: 'left'
                                    markup: True
                                    
                                    text: '1\n'*100
                                
                        
##                            LeftLabel:
##                                id: video_label
##                                text: '看个锤锤视频'
                            

                    FloatLayout:
                        ColoredGridLayout:
                            id: shadow
                            size_hint: None, None
                            size: root.size
                            pos: [0,0]
                            c0: [0]*3
                            cols: 1
                            opacity: 0
##                            on_touch_up:app.touch_on_layout(args)
##                            idd: 'menu'

                    FloatLayout:
                        id: sidebar
                        size_hint: [None]*2
                        size: [0]*2
                        BlockGridLayout:
                            block_lock: [0]*3 if not self.raised else [1]*3
                            id: sidebar_g
                            rows: 1
                            size_hint: None,None
                            raised: False
                            size: root.size
                            pos: -root.size[0],0

                            ColoredGridLayout:
                                reset_c0: app.bg_color
                                id: sidebar_visiable
                                size_hint: 5,1
                                cols: 1

                                ScrollView:
                                    id: sidebar_s
                                    size_hint_y: 10
##                                    on_scroll_start: None
##                                    on_scroll_stop: None
                                    
                                    GridLayout:
                                        cols: 1
                                        size_hint_y: None
                                        height: self.minimum_height

                                        GridLayout:
                                            cols: 1
                                            size_hint_y: None
                                            height: root.height*.25
                                            canvas.before:
                                                Rectangle:
                                                    source: 'src/star_sky.png'
                                                    size: self.width,self.height
                                                    pos: self.pos
                                            
                                            GridLayout:
                                                cols: 1
                                                size_hint_y: 3

                                            GridLayout:
                                                update_controler: False
                                                id: avatar_image_0
                                                rows: 1
                                                size_hint_y: 2
                                                canvas.before:
                                                    Color:
                                                        rgb: white
                                                        
                                                    Ellipse:
                                                        source: app.avatar_fn if not self.update_controler else ''
                                                        size: self.height,self.height
                                                        pos: self.pos[0]+self.width*.015, self.pos[1]

                                            GridLayout:
                                                rows: 1

                                                Label:
                                                    size_hint_x: None
                                                    width: root.height*.03
                                                    
                                                Label:
                                                    id: avatar_text_0
                                                    color: C('#ffffff')
                                                    text: app.nickname
                                                    font_size: app.font_size
                                                    size_hint_x: None
                                                    width: self.texture_size[0]

                                                Label:
                                                    size_hint_x: None
                                                    width: root.height*.02
                                                    
                                                GridLayout:
                                                    rows: 1
                                                    size_hint_x: None
                                                    width: self.minimum_width
                                                    canvas:
                                                        Color:
                                                            rgb: white
                                                        Line:
                                                            width: 1.01
                                                            rounded_rectangle: (self.center[0]-app.font_size*1.5*.6,self.center[1]-app.font_size*.6*.6,app.font_size*3*.6,app.font_size*1.2*.6,app.font_size*.36,app.font_size*.36,app.font_size*.36,app.font_size*.36,30)

                                                        
                                                    Label:
                                                        color: C('#ffffff')
                                                        font_size: app.font_size*.6
                                                        size_hint_x: None
                                                        width: self.texture_size[0]
                                                        text: 'Lv.5'

                                                Label:
                                                    
                                                GridLayout:
                                                    idd: 'check_in'
                                                    on_touch_up: app.touch_on_layout(args)
                                                    size_hint_x: None
                                                    width: self.minimum_width
                                                    
                                                    rows: 1
                                                    canvas:
                                                        Color:
                                                            rgb: white
                                                        Line:
                                                            width: 1.01
                                                            rounded_rectangle: (self.center[0]-app.font_size*1.5,self.center[1]-app.font_size*.6,app.font_size*3,app.font_size*1.2,app.font_size*.6,app.font_size*.6,app.font_size*.6,app.font_size*.6,30)
                                                    Label:
                                                        color: C('#ffffff')
                                                        font_size: app.font_size
                                                        size_hint_x: None
                                                        width: self.texture_size[0]
                                                        text: '签到'
                                                        
                                                Label:
                                                    size_hint_x: None
                                                    width: root.height*.03

                                        GridLayout:
                                            cols: 1
                                            id: sidebar_tools
                                            size_hint_y: None
                                            height: self.minimum_height

                                            SideBarBox:
                                                idd: 'message'
                                                i0: 'src/message.png'
                                                t0: '我的消息'

                                            SideBarBox:
                                                idd: 'vip'
                                                i0: 'src/vip.png'
                                                t0: '会员中心'

                                            SideBarBox:
                                                idd: 'ticket'
                                                i0: 'src/ticket.png'
                                                t0: '云村有票'

                                            SideBarBox:
                                                idd: 'shop'
                                                i0: 'src/shop.png'
                                                t0: '商城'

                                            ColoredGridLayout:
                                                cols: 1
                                                reset_c0: app.bg_color_1 or dark_gray
                                                size_hint_y:None
                                                height: root.height/50

                                            SideBarBox:
                                                idd: 'theme'
                                                i0: 'src/theme.png'
                                                t0: '个性换肤'

                                        LeftLabel:
                                            id: sidebar_left_label
                                            text: ''
                                            
                                GridLayout:
                                    id: sidebar_bottom
                                    rows: 1

                                    Label:
                                        size_hint_x: None
                                        width: root.width*.03
                                        
                                    GridLayout:
                                        idd: 'night'
                                        size_hint_x: None
                                        width: self.minimum_width
                                        on_touch_up: app.touch_on_layout(args)
                                        rows: 1
                                        Image:
                                            size_hint_x: None
                                            width: self.height
                                            source: 'src/night.png'
                                            
                                        FixedHeightLeftLabel:
                                            text: '夜间模式'
                                            font_size: app.font_size*.7
                                            

                                    Label:
                                        
                                    GridLayout:
                                        idd: 'setting'
                                        size_hint_x: None
                                        width: self.minimum_width
                                        on_touch_up: app.touch_on_layout(args)
                                        rows: 1
                                        Image:
                                            size_hint_x: None
                                            width: self.height
                                            source: 'src/setting.png'
                                            
                                        FixedHeightLeftLabel:
                                            text: '设置'
                                            font_size: app.font_size*.7

                                    Label:
                                        
                                    GridLayout:
                                        idd: 'exit'
                                        size_hint_x: None
                                        width: self.minimum_width
                                        on_touch_up: app.touch_on_layout(args)
                                        rows: 1
                                        Image:
                                            size_hint_x: None
                                            width: self.height
                                            source: 'src/exit.png'
                                            
                                        FixedHeightLeftLabel:
                                            text: '退出'
                                            font_size: app.font_size*.7

                                    Label:
                                        size_hint_x: None
                                        width: root.width*.03
                                        
                            Label:
                                idd: 'menu'
                                opacity: 0
                                on_touch_up:app.touch_on_layout(args)

        ColoredGridLayout:
            reset_c0: app.bg_color
            id: playbar
            loop_status: app.loop_status
            cols: 1
            size_hint: 1,0
            height: 0 
            c1: app.theme_color

            Label:
                size_hint_y: .1
                
            GridLayout:
                rows: 1
                idd: 'song_detail'
                on_touch_up: app.touch_on_layout(args)
                Label:
                    size_hint_x: None
                    width: self.height*.1
                    
                Image:
                    id: current_song_cover
                    size_hint_x: None
                    width: self.height
                    source: 'src/avatar.jpg'
                    

                GridLayout:
                    cols: 1
##                    size_hint_x: None
##                    width: self.minimum_width

                    ShortenLabel:
                        id: playbar_song_name
                        font_size: self.height*.6
                        size_hint_y: 2
                        text: ''

                    FixedHeightLeftLabel:
                        size_hint_y: 1
                        color: C(hex_light_black)
                        font_size: self.height*.9
                        text: '横划也切换不了上下首哦' if self.parent.height else ''

                GridLayout:
                    rows: 1
                    size_hint_x: None
                    width: self.minimum_width
                    pos: self.parent.pos[0]+self.parent.width*.95-self.width,self.pos[1]
                    
                    Image:
                        id: playbar_status
                        idd: 'play_or_stop'
                        allow_stretch: True
                        color: (self.parent.parent.parent.c1 or common)+[1]
                        on_touch_up: app.touch_on_layout(args)
                        size_hint_x: None
                        width: self.height*.8
                        source: 'src/playing.png' if root.is_playing else 'src/pausing.png'

                    Label:
                        size_hint_x: None
                        width: self.height*.7
                        
                    Image:
                        id: loop_stt
                        idd: 'change_loop_status'
                        allow_stretch: True
                        color: (self.parent.parent.parent.c1 or common)+[1]
                        on_touch_up: app.touch_on_layout(args)
                        size_hint_x: None
                        width: self.height*.8
                        source: app.total_loop_kind[self.parent.parent.parent.loop_status]

##                Label:

            Label:
                size_hint_y: .1

    Screen:
        name: 'search'
        current_pl_id: 'search'
        current_playlist: []
        
        ColoredGridLayout:
            reset_c0: app.bg_color
            cols: 1
            ColoredGridLayout:
                rows: 1
                size_hint_y: None
                height: root.width*.1
                Image:
                    idd: 'back'
                    on_touch_up: app.touch_on_layout(args)
                    size_hint_x: None
                    height: self.width
                    source: 'src/arrow_left.png'

                GridLayout:
                    rows: 1
                    
                    TextInput:
                        id: search_bar
                        hint_text: 'G.E.M.邓紫棋'
                        hint_text_color: (1,1,1,.6)
                        on_text_validate: app.touch_on_layout([None]*2, 'search_music')
                        multiline: False
                        use_bubble: True
                        use_handles: True
                        

                    Image:
                        idd: 'search_music'
                        on_touch_up: app.touch_on_layout(args)
                        size_hint_x: None
                        height: self.width
                        source: 'src/search.png'
                        
            ColoredGridLayout:
                rows: 1
                size_hint_y: None
                height: root.height*.05
                Label:
                    font_size: app.font_size
                    text: '综合'

                Label:
                    font_size: app.font_size
                    text: '单曲'
                
                Label:
                    font_size: app.font_size
                    text: '视频'

                Label:
                    font_size: app.font_size
                    text: '歌手'

                Label:
                    font_size: app.font_size
                    text: '专辑'
            GridLayout:
                rows: 1
                size_hint_y: None
                height: root.height*.05

                GridLayout:
                    rows: 1
                    Image:
                        idd: 'play_all_songs'
                        on_touch_up: app.touch_on_layout(args)
                        source: 'src/pausing.png'
                        color: app.theme_color+[1]
                        size_hint_x: None
                        width: self.height

                    FixedHeightLeftLabel:
                        text: '播放全部'
                        font_size: app.font_size

                    Label:

                    Label:
                        text: '查看更多>'
                        color: C(hex_light_black)
                        font_size: app.font_size*.7
                        size_hint_x: None
                        width: len(self.text)*self.font_size

            SongsRecycleView:
                id: search_m_l_sv 

    Screen:
        name: 'login'
        ColoredGridLayout:
            reset_c0: app.bg_color
            cols: 1

            Label:
                size_hint_y: None
                height: root.height*.15
                
            GridLayout:
                rows: 1
                size_hint: None,None
                height: root.height*.1
                width: self.minimum_width
                center: root.center[0], self.center[1]
                
                Image:
                    size_hint_x: None
                    width: self.height
                    source: 'src/login_logo.png'
                    color: [1,0,0,1]
                    
                FixedHeightLeftLabel:
                    text: 'NCMusic'
                    font_size: self.height
                    
            Label:
                size_hint_y: None
                height: root.height*.05

            GridLayout:
                cols: 1
                c0: app.bg_color_1 or common
                size_hint: None, None
                width: root.width*.8
                height: self.minimum_height
                canvas.before:
                    Color:
                        rgb: self.c0 or common
                    RoundedRectangle:
                        radius: [self.height*.5]
                        pos: self.pos
                        size: self.size
                
                center: root.center[0], self.center[1]

                TextInput:
                    on_text: root.ids['login_gl'].loginEnable=(self.text and root.ids['t_i_pd'].text)
                    halign: 'center'
                    cursor_color: [1,0,0,1]
                    foreground_color: [0]*3+[1]
                    hint_text: '目前仅支持手机号登录'
                    size_hint: 1, None
##                    width: root.width*.5
                    height: root.height*.07
                    center: root.center[0], self.center[1]
                    id: t_i_un
                    
            Label:
                size_hint_y: None
                height: root.height*.05

            GridLayout:
                cols: 1
                c0: app.bg_color_1 or common
                size_hint: None, None
                width: root.width*.8
                height: self.minimum_height
                canvas.before:
                    Color:
                        rgb: self.c0 or common
                    RoundedRectangle:
                        radius: [self.height*.5]
                        pos: self.pos
                        size: self.size
                
                center: root.center[0], self.center[1]

                TextInput:
                    on_text: root.ids['login_gl'].loginEnable=(self.text and root.ids['t_i_un'].text)
                    halign: 'center'
                    cursor_color: [1,0,0,1]
                    foreground_color: [0]*3+[1]
                    size_hint: None, None
                    width: root.width*.5
                    height: root.height*.07
                    center: root.center[0], self.center[1]
                    id: t_i_pd
                    password: True

            Label:
                size_hint_y: None
                height: root.height*.1
            
            GridLayout:
                id: login_gl
                cols: 1
                size_hint: None, None
                height: root.height*.1
                width: self.height
                center: root.center[0], self.center[1]
                loginEnable: False
                canvas.before:
                    Color:
                        rgb: (app.bg_color_1 or dark_gray) if not self.loginEnable else app.theme_color

                    Ellipse:
                        size: self.size
                        pos: self.pos
                        
                Image:
                    idd: 'login'
                    on_touch_down: app.touch_on_layout(args) if self.parent.loginEnable else print('Pass')
                    source: 'src/arrow_left.png'
                    angle: -180
                    canvas.before:
                        PushMatrix
                        Rotate:
                            angle: self.angle or 0
                            axis: 0, 0, 1
                            origin: self.center
                    canvas.after:
                        PopMatrix

            Label:

    Screen:
        current_pl_id: None
        name: 'music_list'
        current_pl_id: '0000'
        current_playlist: []
        
        ColoredGridLayout:
            reset_c0: app.bg_color
            cols: 1
            
            GridLayout:
                size_hint_y: None
                height: root.height*.3
                canvas.before:
                    Color:
                        rgb: dark_gray
                    Rectangle:
                        pos: self.pos
                        size: self.size
                    
                cols: 1
                GridLayout:
                    rows: 1
                    GridLayout:
                        rows: 1
                        Image:
                            idd: 'back'
                            on_touch_up: app.touch_on_layout(args)
                            
                            source: 'src/arrow_left.png'
                            
                        FixedHeightLeftLabel:
                            text: '歌单'

                    Label:
                        size_hint_x: 3

                    GridLayout:
                        rows: 1
                        Image:
                            source: 'src/search.png'

                        Image:
                            source: 'src/point.png'

                GridLayout:
                    rows: 1
                    size_hint_y: 2
                    Image:
                        id: big_pl_cover
                        allow_stretch: True
                        source: 'src/avatar.jpg'

                    GridLayout:
                        cols: 1
                        
                        FixedHeightLeftLabel:
                            id: pl_name
                            text: '我喜欢的音乐'

                        GridLayout:
                            rows: 1
                            Image:
                                id: creator_avatar
                                size_hint_x: None
                                width: self.height
                                source: 'src/avatar.jpg'

                            FixedHeightLeftLabel:
                                id: creator_name
                                text: app.nickname

                    Label:
                            
                GridLayout:
                    rows: 1
                    Image:
                        source: 'src/comment.png'

                    Image:
                        source: 'src/share.png'

                    Image:
                        source: 'src/download.png'

                    Image:
                        source: 'src/muti_choice.png'
                
                        
            GridLayout:
                rows: 1
                idd: 'play_all_songs'
                on_touch_up: app.touch_on_layout(args)
                size_hint_y: None
                height: root.height*.05

                Image:
                    size_hint_x: None
                    width: self.height
                    color: app.theme_color+[1]
                    source: 'src/pausing.png'
                    
                FixedHeightLeftLabel:
                    text: '播放全部'

            SongsRecycleView:
                id: m_l_sv
                
    Screen:
        name: 'song_lyric'
        lyric_dict: {}
        liked: False

        ColoredGridLayout:
            cols: 1
            reset_c0: app.bg_color_2

            GridLayout:
                rows: 1
                size_hint_y: None
                height: root.height*.1
                
                Image:
                    idd: 'back'
                    on_touch_up: app.touch_on_layout(args)
                    size_hint_x: None
                    width: self.height*.8
                    allow_stretch: True
                    color: app.theme_color+[1,]
                    source: 'src/arrow_left.png'
                Label:
                    size_hint_x: None
                    width: root.width*.02

                GridLayout:
                    cols: 1
                    FixedHeightLeftLabel:
                        id: ly_sn
                        size_hint_y: 1.5
                        text: 'SongName'
                    FixedHeightLeftLabel:
                        id: ly_an
                        text: 'AuthorName'

            ScrollView:
                id: lyric_sv
                size_hint_y: None
                height: root.height*.7
                GridLayout:
                    cols: 1
                    size_hint_y: None
                    height: self.minimum_height
                    Label:
                        id: lyric_label
                        size_hint_y: None
                        font_size: app.font_size
                        line_height: 2
                        color: [0]*3+[1]
                        text_size: self.size[0], None
                        height: self.texture_size[1]
                        halign: 'center'
                        markup: True
                        
                        text: '正在加载...'

            GridLayout:
                rows: 1

                Label:
                    id: current_time
                    size_hint_x: None
                    width: root.width*.1
                    color: app.bg_color+[1]
                    text: app.format_time(play_slider.value_normalized * getattr(app,'current_song_length',0))

                Slider:
                    id: play_slider
                    idd: 'play_slider'
                    lock: False
                    value_track: True
                    on_lock: self.cursor_size= [self.cursor_size[0]*2]*2 if self.lock else [self.cursor_size[0]*.5]*2
                    on_touch_down: app.touch_on_layout(args, False, 'on')
                    on_touch_up: app.touch_on_layout(args, 'play_slider', 'up')
                    value_track_color: app.theme_color+[1]
                    cursor_image: 'src/curcor.png'
                    
                Label:
                    id: song_length
                    size_hint_x: None
                    width: root.width*.1
                    color: app.bg_color_1+[1]
                    text: 'TotalTime'

            GridLayout:
                rows: 1

                Label:
                    size_hint_x: None
                    width: root.width*.1
                AnchorLayout:
                    anchor_x: 'left'
                    anchor_y: 'center'
                    Image:
                        idd: 'like'
                        on_touch_down: app.touch_on_layout(args)
                        size_hint: None,None
                        height: self.parent.height*.5
                        color: C('#d81e06') if self.parent.parent.parent.parent.liked else [1]*4
                        source: 'src/like.png'
                        
                AnchorLayout:
                    anchor_x: 'center'
                    anchor_y: 'center'
                    Image:
                        idd: 'play_previous_song'
                        on_touch_up: app.touch_on_layout(args)
                        size_hint: None,None
                        height: self.parent.height*.5
                        source: 'src/previous.png'
                        
                AnchorLayout:
                    anchor_x: 'center'
                    anchor_y: 'center'
                    Image:
                        idd: 'play_or_stop'
##                        allow_stretch: True
                        color: app.theme_color+[1]
                        on_touch_up: app.touch_on_layout(args)
                        source: 'src/playing.png' if root.is_playing else 'src/pausing.png'
                        
                AnchorLayout:
                    anchor_x: 'center'
                    anchor_y: 'center'
                    Image:
                        idd: 'play_next_song'
                        on_touch_up: app.touch_on_layout(args)
                        size_hint: None,None
                        height: self.parent.height*.5
                        source: 'src/next.png'
                AnchorLayout:
                    anchor_x: 'right'
                    anchor_y: 'center'
                    Image:
                        size_hint: None,None
                        height: self.parent.height*.5
                        source: 'src/avatar.jpg'
                Label:
                    size_hint_x: None
                    width: root.width*.1















